{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-06-16T02:48:18.767022800Z",
     "start_time": "2024-06-16T02:48:13.071234200Z"
    }
   },
   "outputs": [],
   "source": [
    "import torch\n",
    "\n",
    "from wenet.utils.init_model import init_model\n",
    "from gxl_ai_utils.utils import utils_file\n",
    "from gxl_ai_utils.config.gxl_config import GxlNode\n",
    "\n",
    "config_path = \"/home/work_nfs8/xlgeng/new_workspace/wenet_gxl_salmonn_TTS/examples/aishell/ASR_TTS/conf/train_TTS_embedding_only.yaml\"\n",
    "configs = utils_file.load_dict_from_yaml(config_path)\n",
    "args_dict = {\n",
    "    ''\n",
    "}\n",
    "args = GxlNode(args_dict)\n",
    "device = torch.device(\"cuda:0\")\n",
    "model, configs = init_model(args, configs)\n",
    "model = model.to(device)\n",
    "\n",
    "labels = torch.randint(1, 120000, size=(3, 20), dtype=torch.int32, device=device)\n",
    "labels_len = torch.tensor([20, 15, 19], dtype=torch.int32, device=device)\n",
    "\n",
    "npy_input = torch.randint(3, 4096, size=(3, 120), dtype=torch.float32, device=device)\n",
    "npy_len = torch.tensor([120, 119, 113], dtype=torch.int32, device=device)\n",
    "input_dict = {\n",
    "    \"target\": labels,\n",
    "    \"target_lengths\": labels_len,\n",
    "    \"npy\": npy_input,\n",
    "    \"npy_lengths\": npy_len,\n",
    "}\n",
    "loss = model(input_dict)\n",
    "print(loss)\n"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "3ff65501843c56b3"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
